const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 0,
    winWidth: 0,
    winHeight: 0,
    scrollleft: 0,
    currentTab: 0,
    navHeight: 0,
    busList: [
      { bus_type: '0', ply_type: '1', start: '汽车城', end: '虹桥线', time: '06:30', money: '$60' },
      { bus_type: '1', ply_type: '0', start: '汽车城', end: '虹桥线', time: '06:30', money: '$60' },
      { bus_type: '0', ply_type: '2', start: '汽车城', end: '虹桥线', time: '06:30', money: '$60' },
      { bus_type: '2', ply_type: '3', start: '汽车城', end: '虹桥线', time: '06:30', money: '$60' }
    ], // bus_type 0: 个人上下班 1: 企业包车 2临时包车  ply_type 0待支付 1已支付 2已完成 3审核中
  },
   /** 
   * 滑动切换tab 
   */
  bindChange: function (e) {
    var that = this;
    that.setData({
      currentTab: e.detail.current
    });
    this.checkCor();
  },

  checkCor: function () {
    if (this.data.currentTab > 4) {
      this.setData({
        scrollleft: 300
      })
    } else {
      this.setData({
        scrollleft: 0
      })
    }
  },
  /** 
   * 点击tab切换 
   */
  swichNav: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current,
      })
    }
  },
  goDoom() {
    wx.navigateTo({
      url: '/pages/orderdetails/orderdetails',
    })
  },
  invoiceGo: function () {
    wx.navigateTo({
      url: '/pages/invoice/invoice',
    })
  },
  lookOrder: function () {
    wx.navigateTo({
      url: '/pages/orderaudit/orderaudit',
    })
  },
  payOrder: function () {
    wx.navigateTo({
      url: '/pages/orderok/orderok',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let _that = this
    _that.setData({
      currentTab: options.id
    });
    /** 
 * 获取系统信息 
 */
    wx.getSystemInfo({
      success: function (res) {
        _that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight,
          navHeight: app.globalData.navHeight + 1,
        });
      }
    });
  }
})